package com.daocheng.weblog.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @ClassName ThreadPoolConfig
 * @author: 稻城
 * @date: 2025/3/15
 * @Version 1.0
 * @description: 线程池创建，阅读量+1
 */
@Configuration
@EnableAsync
public class ThreadPoolConfig {
    @Bean("threadPoolTaskExecutor")
    public ThreadPoolTaskExecutor threadPoolExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10); //核心线程数
        executor.setMaxPoolSize(20); //最大线程数
        executor.setQueueCapacity(100); //队列容量
        executor.setThreadNamePrefix("WeblogThreadPool-");//线程名前缀
        executor.initialize();
        return executor;
    }
}
